﻿using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class TJ_BLSHJGModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                InitPage();
            }


        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.ToString("yyyy-01-01 07:30:00");
            this.EndDate.Text = DateTime.Now.ToString("yyyy-MM-dd 07:30:00");
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {

            DateTime dateStart = Convert.ToDateTime(this.StartDate.Text);
            DateTime dateEnd = Convert.ToDateTime(this.EndDate.Text);
            string start1 = dateStart.ToString();
            string end1 = dateEnd.ToString();


            string center = Convert.ToString(this.Center.Text);
            string Station = Convert.ToString(this.Station.Text);
            string PersonName = Convert.ToString(this.PersonName.Text);

            string workID = Convert.ToString(this.workID.Text);

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_BLSHJG.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });


            TJDAL dal = new TJDAL();

            DataTable dt = dal.Get_TJ_BLSHJG(dateStart, dateEnd, center, Station, PersonName, workID);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForBLSHJG", dt));

            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}